package Smallprogram.serlet;

import Smallprogram.entiy.Directory;
import Smallprogram.servict.DirectoryServiet;
import Smallprogram.servict.impl.DirectoryServictImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "lisnemServlet", value = "/lisnemServlet")
public class lisnemServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        DirectoryServiet dir=new DirectoryServictImpl();
        List<Directory> list=dir.LISTDirectory();
        String listnem= JSON.toJSONString(list);
        PrintWriter out= response.getWriter();
        if (list!=null){
            out.print(listnem);
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
}
